<?php

namespace App\Models\Dynamic;

use App\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

class SamGlucose extends Model
{
    protected $table = "tn_sam_glucose";

    protected $fillable = [
        'id', 'userid', 'value', 'currentvalue', 'collectedtime', 'createdtime'
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function user()
    {
        return $this->hasMany(User::class);
    }

    public function scopeGetListByUIdByTime(Builder $builder, $userid, $startTime, $endTime)
    {
        return $builder->whereUserid($userid)->whereBetween('collectedtime', [$startTime, $endTime]);
    }


}
